package com.longteng.lesson2.service;

import com.longteng.lesson2.dao.IUserDao;
import com.longteng.lesson2.dao.impl.UserDao;
import org.assertj.core.util.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by li
 * DATE : 2018/12/9 0009
 * TIME : 22:58
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:55324936@qq.com">li</a>
 */
@Service
public class UserService {
    @Autowired
    @Qualifier("newUserDao")
    IUserDao iUserDao;

    public IUserDao getiUserDao() {
        return iUserDao;
    }

    public void setiUserDao(IUserDao iUserDao) {
        this.iUserDao = iUserDao;
    }
    //20个方法,我要一个方法一个方的加
    //我需要对代码进行改造，因为原来的代码是没有监听rt运行时间的，就需要增加代码，
    //然后某个一天可能因为增加了监听触发了一个大的缺陷
    public void update(String name){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public String select(String name){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return null;
    }

    public void add(String userName){

        //做了一些xxx逻辑
        //开始时间
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        iUserDao.addUserName(userName);


        //结束时间
    }

    public List hi(String arg){
        System.out.println("我是hi方法的输出:"+arg);
        List list= Lists.newArrayList();
        list.add(arg);
        return list;
    }

    public void throwTest(String sss) throws Exception {
        String s =null;
        System.out.println(s.getBytes());
    }

    public void delete(){
        System.out.println("删除方法");
    }

}
